<?php
// 加载通用文件
require_once __DIR__ . '/../../common/autoload.php';

// 检查是否已安装
if (!file_exists(__DIR__ . '/../../.installed') && basename($_SERVER['PHP_SELF']) !== 'install.php') {
    header('Location: /install.php');
    exit;
}

// 检查登录状态（除登录页面外）
if (basename($_SERVER['PHP_SELF']) !== 'login.php') {
    check_login();
}

// 验证用户是否有厨师权限
$current_user = current_user();
if (!$current_user || ($current_user['role'] != 'chef' && $current_user['role'] != 'admin')) {
    header('Location: /chushi/login.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>餐饮厨师系统</title>
    <!-- CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css">
    <link rel="stylesheet" href="/assets/css/style.css">
    <!-- 加载厨师端特定样式 -->
    <link rel="stylesheet" href="/chushi/assets/css/chef.css">
</head>
<body>
    <div class="admin-layout">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="sidebar-header">
                <div class="sidebar-logo">厨师工作站</div>
            </div>
            <div class="sidebar-menu">
                <a href="/chushi/index.php" class="sidebar-menu-item <?php echo basename($_SERVER['PHP_SELF']) === 'index.php' ? 'active' : ''; ?>">
                    <i class="fas fa-home"></i> <span>首页</span>
                </a>
                <a href="/chushi/orders.php" class="sidebar-menu-item <?php echo basename($_SERVER['PHP_SELF']) === 'orders.php' ? 'active' : ''; ?>">
                    <i class="fas fa-utensils"></i> <span>待处理订单</span>
                </a>
                <a href="/chushi/history.php" class="sidebar-menu-item <?php echo basename($_SERVER['PHP_SELF']) === 'history.php' ? 'active' : ''; ?>">
                    <i class="fas fa-history"></i> <span>历史订单</span>
                </a>
                <a href="/chushi/logout.php" class="sidebar-menu-item">
                    <i class="fas fa-sign-out-alt"></i> <span>退出登录</span>
                </a>
            </div>
        </div>
        
        <!-- 主内容区 -->
        <div class="main-content">
            <!-- 头部导航 -->
            <div class="header">
                <button class="mobile-nav-toggle d-md-none">
                    <i class="fas fa-bars"></i>
                </button>
                <div class="header-title">
                    <?php 
                    $page_title = '厨师工作站';
                    switch (basename($_SERVER['PHP_SELF'])) {
                        case 'index.php': $page_title = '厨师工作站 - 首页'; break;
                        case 'orders.php': $page_title = '待处理订单'; break;
                        case 'history.php': $page_title = '历史订单'; break;
                    }
                    echo $page_title;
                    ?>
                </div>
                <div class="user-info">
                    <?php if ($current_user): ?>
                    <span class="user-name">
                        <i class="fas fa-user"></i> <?php echo htmlspecialchars($current_user['name']); ?>
                    </span>
                    <a href="/chushi/logout.php" class="btn btn-sm btn-secondary">
                        <i class="fas fa-sign-out-alt"></i> 退出
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            
            <!-- 提示消息容器 -->
            <div id="alert-container" class="mt-3"></div>
            
            <!-- 主要内容 --> 